using Blog.Core.Entities;
using Blog.Infrastructure.DataAcces.Repositories.Abstractisations;
using NHibernate;
using NHibernate.Criterion;

namespace Blog.Infrastructure.DataAcces.Repositories.Implementaions
{
    public class UserRepository:Repository<User>,IUserRepository
    {
        public UserRepository(ISessionFactory sessionFactory) : base(sessionFactory)
        {
        }

        public User GetByLogin(string loginName)
        {

            return _session
                .CreateCriteria(typeof (User))
                .Add(Expression.Eq("LoginName", loginName)).UniqueResult<User>();
        }
    }
}